package fy.test.db;

import fy.config.FyConfig;
import fy.util.DBUtil;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;


public class DBQuery {

	public static void main(String[] args) {
		Connection conn = null;
		Statement st = null;
		ResultSet rs = null;

		try {
			FyConfig.setOA_DB_CONFIG("v3xuser", "fyoa2009",
				"jdbc:oracle:thin:@10.111.0.53:1521:oadb", "oadb",
				"oracle.jdbc.driver.OracleDriver");
                        conn = DBUtil.connect(FyConfig.getOA_DB_CONFIG());
                        conn.setAutoCommit(false);
			st = conn.createStatement();

			rs = st.executeQuery("select t.table_name, t.column_name from user_tab_cols t where t.data_type like 'NUMBER%'");

			List<String[]> list = new ArrayList<String[]>();

			while (rs.next()) {
				String[] array = { rs.getString(1), rs.getString(2) };
				list.add(array);
			}

			DBUtil.close(rs);

			System.out.println(list.size());

			for (int i = 0, length = list.size(); i < length; i++) {
				if (list.get(i)[0].indexOf("FORM") == -1) {
					try {
						rs = st.executeQuery("select t." + list.get(i)[1]
								+ " from " + list.get(i)[0] + " t where t."
								+ list.get(i)[1] + " in ( '-5758824346312619414')");

						while (rs.next()) {
							// System.out.println(rs.getString(1));
							System.out.println("字段：" + list.get(i)[1]);
							System.out.println("表：" + list.get(i)[0]);
							System.out.println("*****************************");
							break;
						}
					} catch (Exception e) {
						e.printStackTrace();
						// System.out.println("select t." + list.get(i)[1] +
						// " from "
						// + list.get(i)[0] + " t where t." + list.get(i)[1]
						// + "='0001K71000000000069P'");
					} finally {
                                                conn.rollback();
						DBUtil.close(rs);
					}
				}

			}

		} catch (Exception e) {
			e.printStackTrace();

		} finally {
			DBUtil.close(rs);
			DBUtil.close(st);
			DBUtil.setAutoCommit(conn, true);
			DBUtil.close(conn);
		}
	}

	// BD_DEFDOC 学历信息 bd_psndoc GROUPDEF14
}
